import React, { Component } from 'react'

export default class app extends Component {
    //componentWillMount 初始化 
   static getDerivedStateFromProps(nextProps,nextState){
    // 是一个静态的方法
        console.log("getDrivedStateFromPropsgetDrivedStateFromProps",nextState);
        return {
            myname:nextState.myname.substring(0,4).toUpperCase()+nextState.myname.substring(1)
        }
        // 对状态值进行修改处理 包括初始和更新
        let arr1=[22,323,323]
        let arr2=[22,"dwadawd",'dwadwad',{num:23}]
        let arr3=[...arr1,...arr2]
        console.log(arr3);
        let arr4=[Object.assign(...arr1,...arr2)]
        console.log(arr4);
    }
state={
    myname:"dwada时间时间",
    myage:300
}
  render() {
    return (
      <div>
        <button onClick={()=>{
            this.setState({
                myname:"xiaomingliaoziqiao"
            })
        }}>点击更新</button>
        app-{this.state.myname}-{this.state.myage}
      </div>
    )
  }
}
